<template>
	<div class="detail_content" v-loading="boxLoading">
		<!-- 返回 -->
		<HyPageHeader :title="'应用评审意见'" />
		<!-- 详情区 -->
		<div class="detail_box">
			<div class="detail_top">
				<el-tabs type="card" v-model="activeName">
					<el-tab-pane
						v-for="(item, index) in tabConfig"
						:key="index"
						:disabled="ableTab(item.value)"
						:label="item.label"
						:name="item.value"
					></el-tab-pane>
				</el-tabs>
			</div>
			<div class="detail">
				<!-- 基础信息 -->
				<unit :message="detailData" />
				<!-- 评审会议 -->
				<reviewMeet :message="meetingList" :routerData="routerData" :appInfo="detailData?.appInfo" />
			</div>
		</div>
	</div>
</template>

<script lang="ts" setup>
import HyPageHeader from '/@/components/HyPageHeader/index.vue';
import unit from './components/unit.vue';
import reviewMeet from './components/reviewMeet.vue';
import { getReviewAppDetail } from '/@/api/expertDatabase/evaluate';
import { ElMessage, ElMessageBox } from 'element-plus';
import { computed, ref, reactive, onMounted } from 'vue';
import { useDict } from '/@/hooks/dict';
const { review_type } = useDict('review_type');
import { useRoute, useRouter } from 'vue-router';
const boxLoading = ref(false);
const route = useRoute();
const router = useRouter();
//tabs 应用类别
//可以点击得tab
const activeNameList: any = ref([]);
//默认的tab
const activeName = ref(null);
//不可以点击的tab
const ableTab = (data: any) => {
	if (activeNameList.value.indexOf(data) == -1) {
		return true;
	} else {
		return false;
	}
};
const tabConfig = computed(() => {
	return review_type.value;
});
onMounted(() => {
	let data = route.query;
	routerData.value.tfOp = data.tfOp;
	routerData.value.id = data.id;

	getDetail();
});
let routerData: any = ref({
	tfOp: '', //判断是否为意见上传
	id: '',
});
let detailData: any = ref({
	meetingDetailList: [],
});

const meetingList = computed(() => {
	let data = activeName.value;
	return detailData.value.meetingDetailList.filter((item: any) => {
		return item.baseInfo.reviewType == data;
	});
});
//详情
const getDetail = () => {
	boxLoading.value = true;
	let id = routerData.value.id;
	getReviewAppDetail({ id })
		.then((res) => {
			boxLoading.value = false;
			if (res.code == 0) {
				detailData.value = res.data;
				// activeName.value = res.data.appInfo.appCategory.toString();
				//可以点击的tab
				activeNameList.value = res.data.hasReviewTypeList;
				//默认的tab取最小值
				let sortArr = res.data.hasReviewTypeList.sort((a: any, b: any) => a - b);
				activeName.value = sortArr[0];
			}
		})
		.catch(() => {
			boxLoading.value = false;
		});
};

function handleBack() {
	window.history.length > 1 ? router.go(-1) : router.push('/');
}
</script>

<style lang="scss" scoped>
.detail_content {
	width: 100%;
	height: calc(100vh - 100px);
	padding: 15px;
	padding-bottom: 0px;
	display: flex;
	flex-direction: column;
	.detail_box {
		width: 100%;
		flex: 1;
		overflow: auto;
		.detail_top {
			:deep(.el-tabs__content) {
				padding: 0;
			}
		}
	}

	:deep(.h-full) {
		height: auto;
		margin-bottom: 10px;
	}
}
</style>
